// @ts-ignore
import sign from './MD5SignUtils';
// @ts-ignore
import getuuId from './UUIDUtils';

const REQ_PARAMS = {
  appId: '001',
  bizContent: JSON.stringify({}),
  bizId: '',
  charset: 'utf-8',
  hosCode: '001',
  hosName: '上海天地健康养老',
  ip: '127.0.0.1',
  merchantId: '001',
  method: '',
  // 平台id => { weixin: '03', alipay: '04', APP: '01' }
  pltId: '03',
  requestId: getuuId(),
  rsaType: 'md5',
  terminalId: '000000000',
  timeStamp: new Date().getTime(),
  version: '1.00.01',
};

export default function(data: any){
    let params = Object.assign({},REQ_PARAMS)
    params.bizContent = JSON.stringify(data.bizContent) || REQ_PARAMS.bizContent
    params.method = data.method || REQ_PARAMS.method
    params.bizId = data.bizId || REQ_PARAMS.bizId

    let reqParams = Object.assign({
      sign: sign(params)
    },params)
    return JSON.stringify(reqParams)
}